const a = async function (...args) {
  const [
    { memory },
    {
      dc: { http },
      xe: { set },
    },
  ] = args.slice(-2);
  const ret = await http.form(
    { url: "/ypxy/noPay/listNameNo", data: { type: "DEPT" } },
    { withToken: false }
  );
  const list = [];
  ret.forEach((item) => {
    const { deptName, levelInfo, name, workNo } = item;
    const label = `${deptName}-${workNo}-${name}`;
    if (levelInfo) {
      const findIndex = list.findIndex((i) => i.label === levelInfo);
      if (findIndex !== -1) {
        list[findIndex].children.push({ label, value: label, workNo });
      } else {
        list.push({
          label: levelInfo,
          value: `dept_${label}`,
          children: [{ label, value: label, workNo }],
        });
      }
    } else {
      list.push({ label, value: label, workNo });
    }
  });
  set(memory, "listNameNoList", list);
  console.log(list);
  return list;
};
